import { request } from "@/utils/request.js";

// 获取最热帖子
export const getHotPostAPI = (data) =>
  request("blog/hot", {
    params: {
      current: data.current,
      category: data.category
    }
  })

// 获取最新帖子
export const getNewPostAPI = (data) =>
  request("blog/new", {
    params: {
      current: data.current,
      category: data.category
    }
  })

// 点赞操作
export const toggleLikeAPI = (id) =>
  request.put(`blog/like/${id}`)

// 通过 id 来查询帖子
export const getPostInfoAPI = (id) =>
  request.get(`blog/${id}`)

// 上传帖子图片
export const postPicAPI = (data) => {
  return request({
    url: `blog/upload`,
    method: 'POST',
    data
  });
};
